package practice;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class Main {

	/**
	 Problem statement:
	 Design an efficient scheme for resource utilization tracking
	 
	 Details:
	 Web requests consume resources like email, sms, data etc. web requests are producers.
	 Consumer threads should log the data and keep track of total resources that have been utilized by different clients	 	 
	 **/
	
	public static void main(String[] args) {
		
		Queue queue = new Queue();
		ISink sink = queue;
		ISource source = queue;
		
		IResourceFactory resourceFactory = new ResourceFactory();
		Producer producer = new Producer(sink, resourceFactory);
		
		ExecutorService producerService = Executors.newFixedThreadPool(5);
		
		for (int i = 0; i < 20; i++) {
			producerService.execute(producer);
		}
				
		Consumer consumer = new Consumer(source);
		
		ExecutorService consumerService = Executors.newFixedThreadPool(1);
		consumerService.execute(consumer);			
	}
}
